package com.ququ.syb.mqhandler.service;

import com.ququ.syb.common.constant.RedisKeyConstant;
import com.ququ.syb.mqhandler.fegin.ChannelsRouterFegin;
import com.ququ.syb.mqhandler.redis.RedisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

import java.util.Set;

@Service
public class ChangeChannelMerchantBankCardService {
    @Autowired
    private RedisDao redisDao;
    @Autowired
    private ChannelsRouterFegin channelsRouterFegin;

    public void updateBankcard(String accountid){
        Jedis jedis = redisDao.getJedis();
        try{
            Set<String> payChannelList = jedis.smembers(RedisKeyConstant.BANKCARD_UPDATE_CHANNEL_SET);
            for (String paychannelid: payChannelList)
                channelsRouterFegin.changeBankCard(accountid,paychannelid,null);
        }finally {
            redisDao.close(jedis);
        }
    }
}
